package drds.global_transaction.api.message_codec.request_and_response.transaction.global_transaction.global_transaction_end_status_report;

import drds.global_transaction.api.api.GlobalTransactionStatus;
import drds.global_transaction.api.message_codec.request_and_response.transaction.TransactionResponse;
import lombok.Getter;
import lombok.Setter;

import java.nio.ByteBuffer;

public abstract class GlobalTransactionEndStatusReportResponseMessage extends TransactionResponse
{
	private static final long serialVersionUID = 1L;
	@Setter
	@Getter
	protected GlobalTransactionStatus globalTransactionStatus;

	@Override
	public void decode(ByteBuffer byteBuffer)
	{
		super.decode(byteBuffer);
		globalTransactionStatus = GlobalTransactionStatus.get(byteBuffer.get());
	}

	@Override
	public ByteBuffer putBytesToByteBuffer()
	{
		ByteBuffer byteBuffer = super.putBytesToByteBuffer();
		byteBuffer.put((byte) globalTransactionStatus.ordinal());
		markAsEncode();
		return byteBuffer;
	}

}
